package zhanglu.family.socket.demo.otherdemo.clinet;

import org.apache.log4j.PropertyConfigurator;

import zhanglu.family.socket.bean.ErrMsg;
import zhanglu.family.socket.bean.syncbean.SyncMsgBean;
import zhanglu.family.socket.demo.otherdemo.TestBean;

public class ClientDemo {
    public static void main(String[] args) throws Exception {
        PropertyConfigurator.configure("log4j.properties");

        ClientManager manager = ClientManager.getInstance();

        TestBean bean = new TestBean();
        bean.setDes("第一个，type是0，接不到回复消息");
        SyncMsgBean msg1 = manager.send(bean, 3);
        System.out.println("同步消息1,错误code是：" + msg1.getErrMsg().getErrCode() + "--错误字符key是：" + msg1.getErrMsg() + "--错误描述是：" + msg1.getErrMsg().getErrMsg());

        bean = new TestBean();
        bean.setType(1);
        bean.setDes("第2个，type是1，能收到");
        SyncMsgBean msg2 = manager.send(bean, 3);
        System.out.println("同步消息2,错误code是：" + msg2.getErrMsg().getErrCode() + "--错误字符key是：" + msg2.getErrMsg() + "--错误描述是：" + msg2.getErrMsg().getErrMsg());

        if (msg2.getErrMsg() == ErrMsg.NONE) {
            System.out.println(msg2.getJsonMsg());
        }
    }
}
